package com.yaowk.system.server.service.base;

import com.yaowk.system.server.entity.SysLogin;
import java.lang.Long;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import com.yaowk.system.server.dao.LoginDao;
import com.yaowk.common.db.BaseServiceImpl;
import com.yaowk.system.api.model.Login;
import java.lang.String;
import com.yaowk.system.server.service.ILoginService;

public abstract class LoginServiceBase extends BaseServiceImpl<Login, SysLogin, Long> implements ILoginService {

	@Autowired
	private LoginDao dao;

	@Override protected LoginDao getDao() {
	return dao;
	}

	@Override
	public Login entity2Model(SysLogin entity) {
		Login model = null;
		if(isNotEmpty(entity)){
			model = new Login();
			model.setId(entity.getId());
			model.setCreateTime(entity.getCreateTime());
			model.setIp(entity.getIp());
			model.setUserId(entity.getUserId());
		}
		return model;
	}

	@Override
	public SysLogin model2Entity(Login model) {
		SysLogin entity = null;
		if(isNotEmpty(model)){
			entity = new SysLogin();
			entity.setId(model.getId());
			entity.setCreateTime(model.getCreateTime());
			entity.setIp(model.getIp());
			entity.setUserId(model.getUserId());
		}
		return entity;
	}

	@Override
	public SysLogin updateParams(Login model) {
		SysLogin entity = dao.findOne(model.getId());
		if(isNotEmpty(model.getCreateTime()))
			entity.setCreateTime(model.getCreateTime());
		if(isNotEmpty(model.getIp()))
			entity.setIp(model.getIp());
		if(isNotEmpty(model.getUserId()))
			entity.setUserId(model.getUserId());
		return entity;
	}


}